# -*- coding:utf-8 -*-
# @Time   :  20:12
# @Author : jinzhongyi
# @File   : ep_demo4.py

import datetime
from ExcelProcess_ver2 import read_online_excel, gen_project_dict, project_classification, \
    post_action, post_content,post_project_content
from KdocsDownload import kdocs_download
import schedule
import time

if __name__ == '__main__':
    current_day = datetime.datetime.today()
    # today = datetime.datetime(current_day.year, current_day.month, current_day.day)
    today = datetime.datetime(current_day.year, 11, 7)

    sht_all = read_online_excel(kdocs_download())
    print(sht_all)

    print("========================================================")

    upcoming_projects, project_managers = project_classification(sht_all, today)
    upcoming_count = len(upcoming_projects)

    print('即将开始任务个数', upcoming_count)
    print(project_managers)

    print("========================================================")

    upcoming_contents = post_project_content(upcoming_projects, project_managers)
    print(upcoming_contents)
    print("========================================================")
    print(upcoming_projects)

    final_content = post_content(upcoming_contents)

    # 测试链接
    url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4c0b1f2d-5d6f-4807-9d40-1da4e46b0915'
    # 行员群链接
    # url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6cc5e84f-b163-47c5-b1ce-ec3d75bccfc0'

    coming_result = post_action(url, final_content)
    print(coming_result)
